#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

struct TreeNode
{
    int val;
    struct TreeNode *left;
    struct TreeNode *right;
    TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};

int getDepth(TreeNode *t)
{
    if(!t)
    {
        return 0;
    }
    int left = getDepth(t->left);
    if(left == -1)
    {
        return -1; //-1表示该子树不是平衡二叉树
    }
    int right = getDepth(t->right);
    if(right == -1)
    {
        return -1;
    }
    if(abs(left - right) > 1)
    {
        return -1;
    }
    return max(left, right) + 1;

}

//平衡二叉树
bool IsBalanced_Solution(TreeNode *pRoot)
{
    return getDepth(pRoot) != -1;
}

void test()
{
}

int main()
{
    test();
    return 0;
}